<?php
namespace Admin\Controller;

class OrderController extends CommonController {
    public function index(){
        if(!empty($_GET['name'])) $map['linkman'] = array('like',"%{$_GET['name']}%");
    	$order = D('Orders');
    	$total = $order->where($map)->count();
        $page=new \Think\Page($total,8);
    	$list = $order->where($map)->order('id desc')->limit($page->firstRow.','.$page->listRows)->getAll();
        $pageButton = $page->show();
    	$this->assign('list',$list);
    	$this->assign('total',$total);
        $this->assign('pageButton',$pageButton);
    	$this->display();
    }

    public function fahuo(){
        $id = $_GET['id'];
        $order = D('Orders');
        $data['status'] = 1;
        $order->where("id={$id}")->save($data);
        $this->redirect('index');
    }

    public function detail(){
    	$data['orderid'] = $_GET['id'];
    	$detail = D('Detail');
    	$list = $detail->where($data)->select();
    	$total = $detail->where($data)->count();
    	$this->assign('list',$list);
    	$this->assign('total',$total);
    	$this->display('detail');
    }

    public function del(){
        $id = $_GET['id'];
        $order = D('Orders');
        $order->where("id={$id}")->delete();
        $detail = D('Detail');
        $detail->where("orderid={$id}")->delete();
        $this->redirect('index');
    }
}


?>